package com.jonychen.swagger2demo;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

/**
 * @Description:
 * @Author: kui.chen@100credit.com
 * @Date: 2019/9/18 17:32
 */
public class MyProjectDemo {

    private static String CurrentHourAndMinute() {
        Calendar now = Calendar.getInstance();
        int hour = now.get(Calendar.HOUR_OF_DAY);
        int minute = now.get(Calendar.MINUTE);
        if (hour < 10 && minute < 10) {
            return "0" + hour + ":" + "0" + minute;
        }
        if (hour > 10 && minute < 10) {
            return hour + ":" + "0" + minute;
        }
        if (hour < 10 && minute > 10) {
            return "0" + hour + ":" + minute;
        }
        return hour + ":" + minute;
    }

    public static void main(String[] args) throws ParseException {
        Calendar now = Calendar.getInstance();
        System.out.println("年: " + now.get(Calendar.YEAR));
        System.out.println("月: " + (now.get(Calendar.MONTH) + 1) + "");
        System.out.println("日: " + now.get(Calendar.DAY_OF_MONTH));
        System.out.println("时: " + now.get(Calendar.HOUR_OF_DAY));
        System.out.println("分: " + now.get(Calendar.MINUTE));
        System.out.println("秒: " + now.get(Calendar.SECOND));
        System.out.println("当前时间毫秒数：" + now.getTimeInMillis());
        System.out.println(now.getTime());

        System.out.println(CurrentHourAndMinute());

        Date d = new Date();
        System.out.println(d);
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String dateNowStr = sdf.format(d);
        System.out.println("格式化后的日期：" + dateNowStr);

        String str = "2012-1-13 17:26:33";    //要跟上面sdf定义的格式一样
        Date today = sdf.parse(str);
        System.out.println("字符串转成日期：" + today);
    }


/*    public static void main(String[] args) {
        List<String> personInfoList = new ArrayList<>();
        String name = "jonychen";
        String idCard = "69412070239";
        String phoneNo = "18134";
        String  newString=name + idCard + phoneNo;
        System.out.println(newString);
        personInfoList.add(newString);
        if (personInfoList.indexOf(newString) < 0) {
            System.out.println("access");
            personInfoList.add(newString);
            System.out.println("exit");
        }
        System.out.println(Arrays.toString(personInfoList.toArray()));
    }*/

}
